<!--
 * @Descripttion: 
 * @version: v1.0.0.0
 * @Author: 任飞
 * @Date: 2020-03-27 14:49:22
 * @LastEditors: 任飞
 * @LastEditTime: 2020-03-27 15:14:35
 -->
<template>
  <div class="head-container">
    <!-- 搜索 -->
    <el-input v-model="query.fromType" clearable placeholder="输入文章出处" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-input v-model="query.author" clearable placeholder="输入文章作者" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-button class="filter-item" size="mini" type="primary" icon="el-icon-search" @click="toQuery">搜索</el-button>
    <!-- 新增 -->
    <div style="display: inline-block;margin: 0px 2px;">
      <el-button
        v-if="checkPermission(['ADMIN'])"
        class="filter-item"
        size="mini"
        type="primary"
        icon="el-icon-plus"
        @click="handleAdd">新增</el-button>
    </div>
  </div>
</template>

<script>
import checkPermission from '@/utils/permission' // 权限判断函数

export default {
  data() {
    return {
      query: {
        fromType: "",
        author: ""
      },
      queryTypeOptions: [
        { key: 'id', display_name: '原创' },
        { key: 'name', display_name: '转载' },
        { key: 'description', display_name: '翻译' }
      ]
    }
  },
  methods: {
    checkPermission,
    handleAdd() {
      this.$parent.articleRow = {}
      this.$parent.editShow = true
      // this.$router.push("/material/article")
    },
    toQuery() {
      this.$parent.page = 0
      this.$parent.init()
    }
  }
}
</script>